<template>
  <a-breadcrumb class="breadcrumb">
    <a-breadcrumb-item
      v-for="(item, index) in breadList"
      :key="item.name"
    >
<!--      <a-button type="link" size="small" v-if="index === 0 && name=='statisticsMonitorXq' || name == 'statisticsMonitorEcuXq'" @click="click"> <a-icon type="left" />返回 </a-button>-->
      <template v-if="item.meta.bread !== false">
        <router-link
          v-if="item.name != name && index != 0"
          :to="{ path: item.path === '' ? '/' : item.path }"
        >{{ $t(item.meta.title) }}</router-link>
        <span v-else>{{ $t(item.meta.title) }}</span>
      </template>
    </a-breadcrumb-item>
  </a-breadcrumb>
</template>

<script>
export default {
  data () {
    return {
      name: '',
      breadList: []
    }
  },
  created () {
    this.getBreadcrumb()
  },
  methods: {
    getBreadcrumb () {
      this.breadList = []
      this.name = this.$route.name
      // this.$route.meta.breadList.forEach(item => {
      this.$route.matched.forEach(item => {
        // 面包削导航去掉首页
        if (item.name !== 'index') {
          this.breadList.push(item)
        }
      })
    },
    click(){
      history.go(-1)
    }
  },
  watch: {
    $route () {
      this.getBreadcrumb()
    }
  }
}
</script>

<style scoped>
.breadcrumb {
  height: 36px;
  line-height: 36px;
  background: #fff;
  padding-left: 16px;
  font-size: 14px;
  color: #cdcdcd;
}
</style>
